import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;


public class SocketServer {

	private ServerSocket servSocket;
	private boolean isRunning;
	
	public SocketServer( int port ) {

		this.isRunning = true;
		
		try {
			servSocket = new ServerSocket(port);
			System.out.println("서버를 시작합니다.");

			while(isRunning) {
				
				Socket clientSocket = servSocket.accept();
				System.out.println(clientSocket.getLocalAddress());
				
				new ProcessThread(clientSocket).start();
			}
			
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
	
	public void stopServer( boolean wantToStop ) {
		this.isRunning = wantToStop;
	}
		


	
	
	
}
